set nocompatible
filetype off

"set the runtime path to include Vundle and initialize


let $GIT_SSL_NO_VERIFY='true'
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe' 
Plugin 'taglist.vim'
"Plugin 'hexman.vim'
call vundle#end()	" required

filetype plugin indent on

"let g:ycm_global_ycm_extra_conf ='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'

let g:ycm_register_as_syntastic_checker = 1
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'

"" prevent conflicting YCM and Ultisnips
let g:UltiSnipsExpandTrigger="<c-j>"

let g:syntastic_cpp_compiler='g++'
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_cflags='-I../include -I../../include -I../src -I/home/jy316/myproject/eie_ko/src'
let g:syntastic_cpp_include_dirs = [ '/home/jy316/myproject/eie_ko/include', '/home/jy316/myproject/eie-ko/src', '../include', '../src']
let g:syntastic_cpp_compiler_options = '-std=c++11'
let g:syntastic_cpp_auto_refresh_includes = 1

let mapleader=','
set backspace=indent,eol,start
set fileencoding=utf-8
set fileencodings=utf-8,cp949,ucs-bom
set enc=utf-8 nobomb
set history=100		" keep 50 lines of command line history
set nowrap
set showmatch
set nu
set title
set ruler
set tabstop=4 softtabstop=4 shiftwidth=4
set smarttab
set smartindent
set ai "자동 들여쓰기
set autowrite " :next, :make 등을 이용할 때 자동으로 저장
set hlsearch
set visualbell
set noerrorbells
set showmode
set showcmd
"set expandtap  " tap을 space로 변환
"set cursorline
"set autochdir
"set wildmenu
set laststatus=2
set statusline=%<%F%w%h%m%r[%{&ff}/%Y][%{getcwd()}]%=(col:%c%V\ pos:%o\ line:%l\,%L\ %p%%)
"set statusline=%<%F%w%h%m%r[%{&ff}/%Y]%=(col:%c%V\ pos:%o\ line:%l\,%L\ %p%%)
"set statusline=%<%F%w%h%m%r[%{getcwd()}]%=(col:%c%V\ pos:%o\ line:%l\,%L\ %p%%)

"" Do not use "set paste". It make Ultisnips not working
set pastetoggle=<F12>

let Tlist_Use_Right_Window = 1
let Tlist_WinWidth=40


"" global key mapping
map <silent> <C-h> gT
map <silent> <C-l> gt
map <silent> <C-e> :NERDTreeToggle<CR>
map <silent> <F2> :TlistUpdate<CR>:TlistToggle<CR>

" 선택 상태를 유지한 채 들여쓰기 조정
vnoremap < <gv
vnoremap > >gv

" buffer next, previous
map <silent> b] :bn<CR>
map <silent> b[ :bp<CR>

if !exists("autocommands_loaded")
    let autocommands_loaded = 1

    augroup filetypesettings
        au FileType python map  <silent> <F9> <ESC>:w<CR>:!python %<CR>
        au FileType python map! <silent> <F9> <ESC>:w<CR>:!python %<CR>
        au FileType c,cpp map  <silent> <F9> <ESC>:make<CR>
        au FileType c,cpp map! <silent> <F9> <ESC>:make<CR>
        au FileType c,cpp map  <silent> <F10> <ESC>:!rm %<.o <CR>:make<CR>
    augroup END
endif


"" Strip trailing whitespace (,ss)
function! StripWhitespace()
  let save_cursor = getpos(".")
  let old_query = getreg('/')
  :%s/\s\+$//e
  call setpos('.', save_cursor)
  call setreg('/', old_query)
endfunction
noremap <leader>ss :call StripWhitespace()<CR>

"" Replace four spaces into tab
noremap <leader>rt :%s/    /\t/g<CR>

"" Buffer
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>


"" add key mapping for screen, tmux
"" <Ctrl-V>[[ <key>  <key>
""
map ^[[[A <F1>
map ^[[[B <F2>
map ^[[[C <F3>
map ^[[[D <F4>
map ^[[[E <F5>
map ^[[17~ <F6>
map ^[[18~ <F7>
map ^[[19~ <F8>
map ^[[20~ <F9>
map ^[[21~ <F10>
map ^[[23~ <F11>
map ^[[24~ <F12>



"" gvim에서 한글이 깨질 경우에는 아래 설정을 이용해 영어 메뉴가 나오게 함
"" 출처: http://soooprmx.com/wp/archives/3544
"lang mes en_US
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim


